package com.ghy.springbootsentinel;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/**
 * @author: 卢佳新
 * @version: v1.0
 * @description: com.ghy.springbootsentinel
 * @date:2022/1/3 11:06
 * @Motto 不积跬步，无以至千里；不积小流，无以成江海。
 */
@Service
public class SentinelService {
    //针对资源限流：value是限流的名称
    @SentinelResource(value = "doTest",blockHandler ="blockHandler",fallback = "fallback") //声明限流的资源
    public String doTest(String name){
        return "hello , "+name;
    }
    public String blockHandler(String name, BlockException e){ //降级，限流触发的
        return "被限流了";
    }
    public String fallback(String name){ //熔断触发的
        return "被降级了";
    }
}
